﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;

namespace TechPlus.RuleBase
{
    public class DefaultGreatDataCapacity
    {
        // Fields
        private IList _BufferData;
        private int _SingleSegmentCapacity;
        private const int SINGLE_BUFFER_COUNT = 500;

        // Methods
        public DefaultGreatDataCapacity(IList listData)
        {
            this._SingleSegmentCapacity = 500;
            this._BufferData = listData;
        }

        public DefaultGreatDataCapacity(IList listData, int singleSegmentCapacity)
        {
            this._SingleSegmentCapacity = singleSegmentCapacity;
            this._BufferData = listData;
        }

        public IList GetDataByIndex(int index)
        {
            ArrayList list = new ArrayList();
            int num = (((index + 1) * this._SingleSegmentCapacity) < this._BufferData.Count) ? ((index + 1) * this._SingleSegmentCapacity) : this._BufferData.Count;
            for (int i = index * this._SingleSegmentCapacity; i < num; i++)
            {
                list.Add(this._BufferData[i]);
            }
            return list;
        }

        public int MaxSegment()
        {
            int result = 0;
            int num2 = Math.DivRem(this._BufferData.Count, this._SingleSegmentCapacity, out result);
            return Convert.ToInt32((result > 0) ? (num2 + 1) : num2);
        }
    }
}
